/* Copyright (c) 2004-2024 peigen.info. All rights reserved. */

package info.peigen.hotpot.component.data.repository.beetlsql.util;


import info.peigen.hotpot.common.core.result.PageResult;
import org.beetl.sql.core.page.DefaultPageResult;

/**
 * <b>(BeetlSqlPageResultUtil)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2022/11/21
 */
@SuppressWarnings({"rawtypes", "unused"})
public class BeetlSqlPageResultUtil {
    public static PageResult beetlSqlPageResultFromSuccess(org.beetl.sql.core.page.PageResult beetlSqlPageResult) {
        PageResult pageResult = new PageResult();
        pageResult.fromSuccess(beetlSqlPageResult.getList());
        if (beetlSqlPageResult instanceof DefaultPageResult<?> page) {
            pageResult.setPage((int) page.getPage());
            pageResult.setPageSize(page.getPageSize());
        }
        pageResult.setTotalRow((int) beetlSqlPageResult.getTotalRow());
        pageResult.setTotalPage((int) beetlSqlPageResult.getTotalPage());
        return pageResult;
    }
}